﻿using Inaction.Mapping;
using System.ComponentModel;

namespace Inaction.Business
{
    public partial class Entity<T> : IEditableObject
    {
        public override void BeginEdit()
        {
        }
        public override void CancelEdit()
        {
            foreach (var child in _childs.Values)
            {
                child.CancelEdit();
            }
            if (IsNew || IsDirty || IsDeleted)
            {
                foreach (var property in ClassInfo.Properties)
                {
                    if (IsPropertyDirty(property))
                    {
                        property.SetFieldValue(this, PropertyTracks[property.Index]);
                    }
                }
                MarkNone();
            }
        }

        public override void EndEdit()
        {
        }
    }
}